@@ -13,4 +13,27 @@ class ApplicationController < ActionController::Base |
||
| 13 | 13 |
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
|
| 14 | 14 |
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
|
| 15 | 15 |
end |
| 16 |
+ |
|
| 17 |
+ def upgrade_warning |
|
| 18 |
+ return unless current_user |
|
| 19 |
+ twitter_oauth_check |
|
| 20 |
+ basecamp_auth_check |
|
| 21 |
+ end |
|
| 22 |
+ |
|
| 23 |
+ private |
|
| 24 |
+ def twitter_oauth_check |
|
| 25 |
+ if ENV['TWITTER_OAUTH_KEY'].blank? || ENV['TWITTER_OAUTH_SECRET'].blank? |
|
| 26 |
+ if @twitter_agent = current_user.agents.where("type like 'Agents::Twitter%'").first
|
|
| 27 |
+ @twitter_oauth_key = @twitter_agent.options['consumer_key'].presence || @twitter_agent.credential('twitter_consumer_key')
|
|
| 28 |
+ @twitter_oauth_secret = @twitter_agent.options['consumer_secret'].presence || @twitter_agent.credential('twitter_consumer_secret')
|
|
| 29 |
+ end |
|
| 30 |
+ end |
|
| 31 |
+ end |
|
| 32 |
+ |
|
| 33 |
+ def basecamp_auth_check |
|
| 34 |
+ if ENV['THIRTY_SEVEN_SIGNALS_OAUTH_KEY'].blank? || ENV['THIRTY_SEVEN_SIGNALS_OAUTH_SECRET'].blank? |
|
| 35 |
+ @basecamp_agent = current_user.agents.where(type: 'Agents::BasecampAgent').first |
|
| 36 |
+ end |
|
| 37 |
+ end |
|
| 38 |
+ |
|
| 16 | 39 |
end |
@@ -8,26 +8,4 @@ class HomeController < ApplicationController |
||
| 8 | 8 |
|
| 9 | 9 |
def about |
| 10 | 10 |
end |
| 11 |
- |
|
| 12 |
- private |
|
| 13 |
- def upgrade_warning |
|
| 14 |
- return unless current_user |
|
| 15 |
- twitter_oauth_check |
|
| 16 |
- basecamp_auth_check |
|
| 17 |
- end |
|
| 18 |
- |
|
| 19 |
- def twitter_oauth_check |
|
| 20 |
- if ENV['TWITTER_OAUTH_KEY'].blank? || ENV['TWITTER_OAUTH_SECRET'].blank? |
|
| 21 |
- if @twitter_agent = current_user.agents.where("type like 'Agents::Twitter%'").first
|
|
| 22 |
- @twitter_oauth_key = @twitter_agent.options['consumer_key'].presence || @twitter_agent.credential('twitter_consumer_key')
|
|
| 23 |
- @twitter_oauth_secret = @twitter_agent.options['consumer_secret'].presence || @twitter_agent.credential('twitter_consumer_secret')
|
|
| 24 |
- end |
|
| 25 |
- end |
|
| 26 |
- end |
|
| 27 |
- |
|
| 28 |
- def basecamp_auth_check |
|
| 29 |
- if ENV['THIRTY_SEVEN_SIGNALS_OAUTH_KEY'].blank? || ENV['THIRTY_SEVEN_SIGNALS_OAUTH_SECRET'].blank? |
|
| 30 |
- @basecamp_agent = current_user.agents.where(type: 'Agents::BasecampAgent').first |
|
| 31 |
- end |
|
| 32 |
- end |
|
| 33 | 11 |
end |
@@ -1,4 +1,6 @@ |
||
| 1 | 1 |
class ServicesController < ApplicationController |
| 2 |
+ before_filter :upgrade_warning, only: :index |
|
| 3 |
+ |
|
| 2 | 4 |
def index |
| 3 | 5 |
@services = current_user.services.page(params[:page]) |
| 4 | 6 |
|
@@ -12,6 +12,8 @@ |
||
| 12 | 12 |
TWITTER_OAUTH_KEY=<%= @twitter_oauth_key %> |
| 13 | 13 |
TWITTER_OAUTH_SECRET=<%= @twitter_oauth_secret %> |
| 14 | 14 |
</pre> |
| 15 |
+ To authenticate new accounts with your twitter OAuth application you need to log in the to <a href="https://apps.twitter.com/" target="_blank">twitter application management page</a> and set the callback URL of your application to "http<%= ENV['FORCE_SSL'] == 'true' ? 's' : '' %>://<%= ENV['DOMAIN'] %>/auth/twitter/callback". |
|
| 16 |
+ |
|
| 15 | 17 |
</p> |
| 16 | 18 |
<% end %> |
| 17 | 19 |
<% if @basecamp_agent %> |
@@ -1,5 +1,4 @@ |
||
| 1 | 1 |
<% if user_signed_in? %> |
| 2 |
- <%= render "upgrade_warning" %> |
|
| 3 | 2 |
<%= render "signed_in_index" %> |
| 4 | 3 |
<% else %> |
| 5 | 4 |
<%= render "signed_out_index" %> |
@@ -24,7 +24,10 @@ |
||
| 24 | 24 |
<%= render 'layouts/messages' %> |
| 25 | 25 |
</div> |
| 26 | 26 |
</div> |
| 27 |
- |
|
| 27 |
+ <% if user_signed_in? %> |
|
| 28 |
+ <%= render "upgrade_warning" %> |
|
| 29 |
+ <% end %> |
|
| 30 |
+ |
|
| 28 | 31 |
<%= yield %> |
| 29 | 32 |
|
| 30 | 33 |
</div> |
@@ -35,6 +35,8 @@ class MigrateAgentsToServiceAuthentication < ActiveRecord::Migration |
||
| 35 | 35 |
TWITTER_OAUTH_KEY=#{twitter_consumer_key(agents.first)}
|
| 36 | 36 |
TWITTER_OAUTH_SECRET=#{twitter_consumer_secret(agents.first)}
|
| 37 | 37 |
|
| 38 |
+ To authenticate new accounts with your twitter OAuth application you need to log in the to twitter application management page (https://apps.twitter.com/) |
|
| 39 |
+ and set the callback URL of your application to "http#{ENV['FORCE_SSL'] == 'true' ? 's' : ''}://#{ENV['DOMAIN']}/auth/twitter/callback"
|
|
| 38 | 40 |
|
| 39 | 41 |
EOF |
| 40 | 42 |
migrated = true |